﻿<div id="Content-Body" style="min-width:1000px;">
    <div class="toggle">
        <span class="data-fill" resource="Admins-Table-Paging">共 @Total 条数据</span>

        <button class="item active">所有管理员</button>
    </div>

    <div class="tools">
        <!--<input type="button" class="button right super-search" resource="Admins-Table" value="高级搜索" />-->
        <form class="filter right" resource="Admins-Table,Admins-Table-Paging">
            <input class="left w280 input" type="text" name="[Fuzzy]UserName_c,[ORFuzzy]Contact" placeholder="搜索登录名或联系人..." /><input type="submit" class="right button" value="Q" />
        </form>

        <!--<input type="button" class="tool button refresh" resource="Admins-Table" value="刷新" />-->
        <input type="button" class="tool button insert" resource="Admins-Table" frame="TempAdminFrame" command="InsertAdmin" value="新增" />
        <input type="button" class="tool button update" resource="Admins-Table" frame="TempAdminFrame" command="UpdateAdmin" value="修改" />
        <input type="button" class="tool button delete" resource="Admins-Table" command="DeleteAdmin" value="删除" />
    </div>

    <div class="table-box">
        <table class="table" id="Admins-Table" command="ReadPageAdmins" parameters="Begin:1,End:12,DefaultOrders:'DId'">
            <thead>
                <tr>
                    <td name="selection" style="width:30px;"><input type="checkbox" /></td>
                    <td class="sort" name="Id" style="width:30px;">ID</td>
                    <td class="sort" name="UserName_c" style="width:80px;">登录名</td>
                    <td class="sort" name="RoleName" style="width:80px;">角色</td>
                    <td class="sort" name="Contact" style="width:80px;">联系人</td>
                    <td class="sort" name="ContactPhone" style="width:80px;">联系电话</td>
                </tr>
            </thead>
        </table>
    </div>

    <div id="Admins-Table-Paging" command="GetAdminsTotal" resource="Admins-Table"></div>

    <form id="TempAdminFrame" text="管理员信息" class="frame temp" onsubmit="return app.frameSubmit(this)" style="width:480px;height:380px;margin-left: 0px; margin-top: 0px; top: 20%; left: 20%;">
        <div class="top">
            <span class="title">查看/修改管理员信息</span>
            <div class="right">
                <span class="min" title="最小化"></span>
                <span class="max" title="最大化"></span>
                <span class="close" title="关闭"></span>
            </div>
        </div>
        <div class="content" readonly-where="data.Readonly">
            <div class="content">
                <span class="title">基本信息</span>
                <input type="hidden" name="Id" />
                <div class="item">
                    <label class="text">*登录名：</label>
                    <input verify="notNull" class="input w280" type="text" name="UserName_c" placeholder="登录名" />
                </div>
                <div class="item">
                    <label class="text">*密码：</label>
                    <input verify="notNull" class="input w280" type="password" name="Password" field="密码" placeholder="密码" />
                </div>
                <div class="item">
                    <label class="text">*角色：</label>
                    <select verify="notNull" class="input none list w280" id="Roles-List" name="Role" field="角色" command="ReadListRoles" menu-name="角色 List"></select>
                </div>
                <div class="item">
                    <label class="text">*联系人：</label>
                    <input verify="notNull" class="input w280" type="text" name="Contact" placeholder="联系人" />
                </div>
                <div class="item">
                    <label class="text">*联系电话：</label>
                    <input verify="notNull,mobileOrPhone" class="input w280" type="text" name="ContactPhone" placeholder="联系电话" />
                </div>
            </div>
        </div>
        <div class="bottom">
            <input type="submit" class="button" value="保存修改" display-where="!data.Readonly" />
            <input type="button" class="button close" value="返回" />
        </div>
    </form>

    <script>
        $("#TempAdminFrame").on("process", function (e, Data) {
            Data.Avatar = "/image/DefaultAvatar.jpg";
            Data.Nickname = Data.Contact || Data.UserName_c;
            Data.Password = Data.Password ? Data.Password : null;
        });

        $("#TempAdminFrame").on("apply", function (e, Data) {
            var IsInsert = $(this).attr("command").indexOf("Insert") != -1;

            if (!IsInsert) {
                $(this).find("[name=Password]").attr("placeholder", "不输入则不修改").css("font-style", "italic").removeAttr("verify");
                $(this).find("[name=UserName_c]").prop("disabled", true);
            }
        });

        $.extend(window, {
        });

        app.control($("#Admins-Table"), "table");
        app.control($("#Admins-Table-Paging"), "paging");
        app.control($("#Content-Body"), "content");
        app.control($("#Roles-List"), "list");
    </script>
</div>